package com.yu.config.result;

import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;


@Data
@AllArgsConstructor
@NoArgsConstructor
public class BasePageResult<T> implements Serializable {

    private Integer page;
    private Integer size;
    //private Integer pageCount;
    private Long total;
    private List<T> content;

    public static BasePageResult build(List list){
        PageInfo<Object> pageInfo = new PageInfo<>(list);
        return new BasePageResult<>(pageInfo.getPageNum(), pageInfo.getPageSize(), pageInfo.getTotal(), pageInfo.getList());
    }

    public static BasePageResult buildByPageInfo(PageInfo<Object> pageInfo) {
        return new BasePageResult<>(pageInfo.getPageNum(), pageInfo.getPageSize(), pageInfo.getTotal(), pageInfo.getList());
    }
}
